import React from "react";


// 通过ref来获取一个东西，把这个东西传给子组件，子组件调用这个东西
// ref的回调函数

// React.forwardRef  返回一个组件
function logProps(Component) {
    class LogProps extends React.Component {
      componentDidUpdate(prevProps) {
        console.log('old props:', prevProps);
        console.log('new props:', this.props);
        console.log('123123')
      }
  
      render() {
        const {forwardedRef, ...rest} = this.props;
  
        return <Component ref={forwardedRef} {...rest} />;
      }
    }
    return React.forwardRef((props, ref) => {
      return <LogProps {...props} forwardedRef={ref} />;
    });
  }

  class Componentt extends React.Component{

    render() {
        return (
             <div>
                hellow
             </div>
        );
    }

  }

  var Canan = logProps(Componentt);
  class App extends React.Component{
    constructor(props){
      super(props)
      this.date_ref=React.createRef();
    }
    componentDidMount(){
      console.log(this.date_ref)
    }
    render() {
      return (
         <Canan ref={this.date_ref}></Canan>
      );
    }
    
  }
  export default App